package com.softstao.guoyu.mvp.presenter.sale;

import com.softstao.guoyu.model.sale.FromOrderList;
import com.softstao.guoyu.model.sale.MonthSales;
import com.softstao.guoyu.model.sale.OrderDetail;
import com.softstao.guoyu.model.sale.PayCondition;
import com.softstao.guoyu.model.sale.ShippingCondition;
import com.softstao.guoyu.model.sale.ToOrderList;
import com.softstao.guoyu.mvp.interactor.sale.OrderInteractor;
import com.softstao.guoyu.mvp.presenter.BasePresenter;
import com.softstao.guoyu.mvp.viewer.BaseViewer;
import com.softstao.guoyu.mvp.viewer.sale.FromAgentOrderListViewer;
import com.softstao.guoyu.mvp.viewer.sale.MonthSalesViewer;
import com.softstao.guoyu.mvp.viewer.sale.OrderDetailViewer;
import com.softstao.guoyu.mvp.viewer.sale.OrderViewer;
import com.softstao.guoyu.mvp.viewer.sale.ToAgentOrderListViewer;

/**
 * Created by vaikus on 2017/6/15.
 */

public class OrderPresenter extends BasePresenter<BaseViewer, OrderInteractor> {
    public void getMonthSales(int agentId){
        interactor.getMonthSales(agentId,o -> ((MonthSalesViewer)viewer).getMonthSales((MonthSales) o));
    }

    public void getFromAgentOrderList(int page, int agentId, String orderState, String search, int isPay){
        interactor.getFromAgentOrderList(page,agentId,orderState,search,isPay,o -> ((FromAgentOrderListViewer)viewer).getOrderList((FromOrderList) o));
    }

    public void getToAgentOrderList(String type,int page, int agentId, String orderState, String search, int isPay){
        switch (type){
            case "to":
                interactor.getToAgentOrderList(page,agentId,orderState,search,isPay,o -> ((ToAgentOrderListViewer)viewer).getOrderList((ToOrderList) o));
                break;
            case "transfer":
                interactor.getTransferOrderList(page,agentId,orderState,search,isPay,o -> ((ToAgentOrderListViewer)viewer).getOrderList((ToOrderList) o));
                break;
        }
    }

    public void getOrderDetail(int agentId, String orderCode){
        interactor.getOrderDetail(agentId,orderCode,o -> ((OrderDetailViewer)viewer).getOrderDetail((OrderDetail) o));
    }

    public void orderCancel(int agentId, String orderCode,String cancelReason){
        interactor.orderCancel(agentId,orderCode,cancelReason,o -> ((OrderViewer)viewer).cancelResult(o));
    }

    public void orderConfirmIncome(int agentId, String orderCode){
        interactor.orderConfirmIncome(agentId,orderCode,o -> ((OrderViewer)viewer).confirmIncomeResult(o));
    }

    public void orderRejectIncome(int agentId, String orderCode, String reason){
        interactor.orderRejectIncome(agentId,orderCode,reason,o -> ((OrderViewer)viewer).rejectIncomeResult(o));
    }

    public void orderSubmitShipping(ShippingCondition condition){
        interactor.orderSubmitShipping(condition,o -> ((OrderViewer)viewer).submitShippingResult(o));
    }

    public void orderPay(PayCondition condition){
        interactor.orderPay(condition,o -> ((OrderViewer)viewer).payResult(o));
    }

    public void orderConfirm(int agentId, String orderCode){
        interactor.orderConfirm(agentId,orderCode,o -> ((OrderViewer)viewer).confirmResult(o));
    }

    public void orderResubmit(int agentId, String orderCode){
        interactor.orderResubmit(agentId,orderCode,o -> ((OrderViewer)viewer).reSubmitResult(o));
    }

    public void orderTransfer(int agentId, String orderCode){
        interactor.orderTransfer(agentId,orderCode,o -> ((OrderViewer)viewer).transferResult(o));
    }

    public void orderReceive(int agentId, String orderCode){
        interactor.orderReceive(agentId,orderCode,o -> ((OrderViewer)viewer).receiveResult(o));
    }

    public void orderRevoke(int agentId, String orderCode){
        interactor.orderRevoke(agentId,orderCode,o -> ((OrderViewer)viewer).revokeResult(o));
    }

    public void orderDelete(int agentId, String orderCode){
        interactor.orderDelete(agentId,orderCode,o -> ((OrderViewer)viewer).deleteResult(o));
    }
}
